﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using _MetalSlug.Soldiers.Units;
using _MetalSlug.Mementoes;
using _MetalSlug.MyCharacters.Characters;

namespace _MetalSlug.Mission
{
    public class ContinueMissionFactory : MissionFactory
    {
        public override void InitialAttributeForEnemy(List<Enemy> lstNewEnemy)
        {
            List<Enemy> RemovedEnemies = new List<Enemy>();
            foreach (Enemy newEnemy in lstNewEnemy)
            {
                IMemento MementoOfNewEnemy = CareTaker.GetInstance().GetEnemyMemento(newEnemy.Id);
                if (MementoOfNewEnemy == null)
                {
                    RemovedEnemies.Add(newEnemy);
                    continue;
                }
                newEnemy.RestoreMemento(MementoOfNewEnemy);
            }

            lstNewEnemy = lstNewEnemy.Where(item=> !RemovedEnemies.Contains(item)).ToList();
        }

        public override void InitialAttributeCharacter(MyCharacter Character)
        {
            if (Character != null)
            {
                Character.RestoreMemento(CareTaker.GetInstance().GetHeroMemento());
                GameUtil.GamePivot.SetPivotPoint(CareTaker.GetInstance().GetMissionMemento().PivotPoint);
            }
        }

        public override void InitialAttributeMap(MyMap Map)
        {
            Map.RestoreMemento(CareTaker.GetInstance().GetMapMemento());
        }
    }
}
